# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=mongo-c-driver
pkgver=1.24.4
pkgrel=1
pkgdesc='A client library written in C for MongoDB'
arch=('loong64' 'x86_64')
url='https://www.mongodb.org/display/DOCS/C+Language+Center'
license=('Apache')
depends=('libsasl' 'icu' 'snappy' 'zlib' 'zstd')
makedepends=('cmake')
provides=('libbson' 'libmongoc')
conflicts=('libbson' 'libmongoc')
replaces=('libbson' 'libmongoc')
source=("https://github.com/mongodb/mongo-c-driver/releases/download/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('3563c061565d17a76581e188f6e184d7e41f2729812c8815afd34e03ebe6c1d25d7498a2cb1b599a09d24f6268c36473ef5113a14c7585a1532c9abf2e56e936')

prepare() {
  mkdir -p build
}

build() {
  cd build
  cmake ../mongo-c-driver-$pkgver \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DENABLE_STATIC=OFF -DENABLE_TESTS=OFF
    # Test profiles are not found even with ENABLE_TESTS=ON
  make
}

check() {
  cd build
  # No test profile found
  # pifpaf run mongodb --port 27017 make test || echo "Tests failed"
}

package() {
  cd build
  make DESTDIR="$pkgdir/" install
}
